<template>
  <div id="app">
    <h1>在线翻译</h1>
    <h5 class="text-muted">简单 / 易用 / 便捷</h5>
    <translateForm v-on:formSubmit="translateTextform"></translateForm>
    <translateOutput v-text="translateOutTextResult"></translateOutput>
  </div>
</template>

<script>
import TranslateForm from "./components/TranslateForm";
import TranslateOutput from "./components/TranslateOutput";
export default {
  name: 'App',
    data: function(){
      return {
          translateOutTextResult: ""
      }
    },
    methods: {
        translateTextform:function(text,translateLang){
            this.$http.get("https://translate.yandex.net/api/v1.5/tr.json/translate?key=" +
                "trnsl.1.1.20190828T035942Z.1f4cbca9e230df80.606d54d50baae553d67f50d4cb67caadb2deb385&lang=" + translateLang
                + "&text=" + text
            ).then((response)=>{
                console.log(response.body.text[0])
                this.translateOutTextResult = response.body.text[0]
            });
        }
    },
    components: {TranslateOutput, TranslateForm}
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
